package org.come.Jpanel;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;

import org.come.entity.Gang;
import org.come.entity.GangGroup;
import org.come.until.ScrollUI;
import org.come.until.SrcollPanelUI;

import com.tool.btn.FactionBtn;
import com.tool.btn.GangGroupBtn;
import com.tool.tcpimg.UIUtils;
import com.updateNew.MyIsif;

 

/**
 * 帮派总览面板
 * 
 * @author HGC<br>
 * @time 2020年1月11日 上午11:26:36<br>
 * @class 类名:FactionPandectJpanel<br>
 */
public class FactionPandectJpanel extends JPanel {

    /**
     * 字段名:btnReward 按钮赏功堂<br>
     * 字段名:btnWarehouse 按钮帮派仓库<br>
     * 字段名:btnFourTiger 图标四圣兽白虎<br>
     * 字段名:btnFourDragon 图标四圣兽青龙<br>
     * 字段名:btnFourRosefinch 图标四圣兽朱雀<br>
     * 字段名:btnFourTortoise 图标四圣兽玄武<br>
     * 字段名:btnDoor 图标门<br>
     * 字段名:btnDye 图标染料坊<br>2023
     * 字段名:btnShop 图标商店<br>
     * 字段名:btnTownHall 图标议政厅<br>
     * 字段名:btnBase 图标主基地<br> 2021
     * 字段名:btnTechfun 图标科技坊<br> 2022
     * 字段名:btnForge 图标锻造<br>
     * 字段名:btnWare 图标仓库<br>
     * 字段名:btnKylin 图标麒麟<br> 2026
     * 字段名:btnTwoTiger 图标双白虎<br> 
     * 字段名:btnTwoDragon 图标双青龙<br>
     */
    private FactionBtn btnReward, btnWarehouse,juanqian;
    private GangGroupBtn btnFourTiger, btnFourDragon, btnFourRosefinch, btnFourTortoise,
    btnDoor, btnDye, btnShop, btnTownHall, btnBase, btnTechfun, btnForge, btnWare, btnKylin, btnTwoTiger,
    btnTwoDragon;
    /**
     * 字段名:btnArrTower 塔图标数组<br>
     */
    private GangGroupBtn[] btnArrTower;

    private JLabel labFactionName, labFactionLvl, labFactionMoney, labFactionNum, labFactionWang;

    private JTextArea textArea;
    private JScrollPane scrollPane;

    private FactionCardJpanel factionCardJpanel;

    public FactionPandectJpanel(FactionCardJpanel factionCardJpanel) {
        this.factionCardJpanel = factionCardJpanel;
        setPreferredSize(new Dimension(662, 475));
        setOpaque(false);
        setLayout(null);

        getLabFactionName();
        getLabFactionLvl();
        getLabFactionMoney();
        getLabFactionNum();
        getLabFactionWang();
        getScrollPane();
        getBtnReward();
        getJuanqian();
        getBtnWarehouse();

        getBtnArrTower();
        getBtnTechfun();
        getBtnTwoDragon();
        getBtnTwoTiger();
        getBtnBase();
        getBtnDoor();
        getBtnDye();
        getBtnForge();
        getBtnKylin();
        getBtnFourDragon();
        getBtnFourRosefinch();
        getBtnFourTiger();
        getBtnFourTortoise();
        getBtnShop();
        getBtnTownHall();
        getBtnWare();
    }

    /** 展示帮派信息 */
    public void showFactionMessage(Gang gang,GangGroup gangGroup) {
        labFactionName.setText(gang.getGangname());
        labFactionLvl.setText(gang.getGanggrade().toString());
        labFactionMoney.setText(gang.getBuilder().toString());
        labFactionNum.setText(gang.getGangnumber().toString());
        labFactionWang.setText(gang.getGangbelong());
        textArea.setText(gang.getIntroduction());
        btnBase.setLvl(gang.getGanggrade().intValue());
        if (gangGroup!=null) {
            btnDye.setLvl(gangGroup.getXy());
            btnTechfun.setLvl(gangGroup.getKj());
        }
    }

    private ImageIcon icon;

    @Override
    protected void paintComponent(Graphics g) {
        // TODO Auto-generated method stub
        super.paintComponent(g);
        if("水墨UI".equals(MyIsif.getStyle())) {
            if (icon == null) {
                icon = new ImageIcon("inkImg/newbackground/B222.png");
            }
            g.drawImage(icon.getImage(), 0, 0, 662, 475, null);
        }else{
            if (icon == null) {
                icon = new ImageIcon("inkImg/hongmu/2/S166.png");
            }
            g.drawImage(icon.getImage(), 0, 0, 662, 475, null);
        }
    }

    public JLabel getLabFactionName() {
        if (labFactionName == null) {
            labFactionName = new JLabel("帮派名称");
            if("水墨UI".equals(MyIsif.getStyle())) {
                labFactionName.setBounds(541, 94, 101, 16);
            }else{
                labFactionName.setBounds(550, 104, 101, 16);
            }
            labFactionName.setFont(UIUtils.TEXT_HY14);
            labFactionName.setForeground(Color.white);
            this.add(labFactionName);
        }
        return labFactionName;
    }

    public void setLabFactionName(JLabel labFactionName) {
        this.labFactionName = labFactionName;
    }

    public JLabel getLabFactionLvl() {
        if (labFactionLvl == null) {
            labFactionLvl = new JLabel("帮派名称");
            if("水墨UI".equals(MyIsif.getStyle())) {

                labFactionLvl.setBounds(541, 136, 101, 16);
            }else{

                labFactionLvl.setBounds(550, 145, 101, 16);
            }
            labFactionLvl.setFont(UIUtils.TEXT_HY14);
            labFactionLvl.setForeground(Color.white);
            this.add(labFactionLvl);
        }
        return labFactionLvl;
    }

    public void setLabFactionLvl(JLabel labFactionLvl) {
        this.labFactionLvl = labFactionLvl;
    }

    public JLabel getLabFactionMoney() {
        if (labFactionMoney == null) {
            labFactionMoney = new JLabel("帮派名称");
            if("水墨UI".equals(MyIsif.getStyle())) {

                labFactionMoney.setBounds(541, 178, 101, 16);
            }else{

                labFactionMoney.setBounds(550, 187, 101, 16);
            }
            labFactionMoney.setFont(UIUtils.TEXT_HY14);
            labFactionMoney.setForeground(Color.white);
            this.add(labFactionMoney);
        }
        return labFactionMoney;
    }

    public void setLabFactionMoney(JLabel labFactionMoney) {
        this.labFactionMoney = labFactionMoney;
    }

    public JLabel getLabFactionNum() {
        if (labFactionNum == null) {
            labFactionNum = new JLabel("帮派名称");
            labFactionNum.setFont(UIUtils.TEXT_HY14);
            labFactionNum.setForeground(Color.white);
            if("水墨UI".equals(MyIsif.getStyle())) {

                labFactionNum.setBounds(541, 220, 101, 16);
            }else{

                labFactionNum.setBounds(550, 229, 101, 16);
            }
            this.add(labFactionNum);
        }
        return labFactionNum;
    }

    public void setLabFactionNum(JLabel labFactionNum) {
        this.labFactionNum = labFactionNum;
    }

    public JLabel getLabFactionWang() {
        if (labFactionWang == null) {
            labFactionWang = new JLabel("帮派名称");
            if("水墨UI".equals(MyIsif.getStyle())) {
                labFactionWang.setBounds(541, 262, 101, 16);

            }else{

                labFactionWang.setBounds(550, 271, 101, 16);
            }
            labFactionWang.setFont(UIUtils.TEXT_HY14);
            labFactionWang.setForeground(Color.white);
            this.add(labFactionWang);
        }
        return labFactionWang;
    }

    public void setLabFactionWang(JLabel labFactionWang) {
        this.labFactionWang = labFactionWang;
    }

    public JTextArea getTextArea() {
        if (textArea == null) {
            textArea = new JTextArea();
            textArea.setOpaque(false);
            textArea.setForeground(Color.white);
            textArea.setFont(UIUtils.TEXT_HY14);
            textArea.setLineWrap(true);
        }
        return textArea;
    }

    public void setTextArea(JTextArea textArea) {
        this.textArea = textArea;
    }

    public JScrollPane getScrollPane() {
        if (scrollPane == null) {
            scrollPane = new JScrollPane(getTextArea());
            scrollPane.setVerticalScrollBarPolicy(22);
            scrollPane.getVerticalScrollBar().setUI(new ScrollUI());
            scrollPane.getViewport().setOpaque(false);
            scrollPane.setOpaque(false);
            if("水墨UI".equals(MyIsif.getStyle())) {

                scrollPane.setBounds(50, 352, 490, 82);
            }else{

                scrollPane.setBounds(56, 362, 490, 88);
            }
            scrollPane.setBorder(BorderFactory.createEmptyBorder());
            scrollPane.setHorizontalScrollBarPolicy(31);
            this.add(scrollPane);
        }

        return scrollPane;
    }

    public void setScrollPane(JScrollPane scrollPane) {
        this.scrollPane = scrollPane;
    }

    public ImageIcon getIcon() {
        return icon;
    }

    public void setIcon(ImageIcon icon) {
        this.icon = icon;
    }

    public FactionBtn getBtnReward() {
        if("水墨UI".equals(MyIsif.getStyle())) {

            if (btnReward == null) {
                btnReward = new FactionBtn("skin/8100226/newbutton/B22.png", 1, UIUtils.COLOR_WHITE2, "赏功堂", UIUtils.TEXT_HY16, 8,
                        this);
                btnReward.setBounds(545, 343, 99, 24);
                this.add(btnReward);

            }
        }else{
            if (btnReward == null) {
                btnReward = new FactionBtn("inkImg/hongmu/1/1_png.button.btn_xy.png", 1, UIUtils.COLOR_BTNPUTONG2, "赏功堂", UIUtils.TEXT_HY88, 8,
                        this);
                btnReward.setBounds(560, 303, 80, 26);
                this.add(btnReward);

            }
        }

    	return btnReward;
    }

    public void setBtnReward(FactionBtn btnReward) {
        this.btnReward = btnReward;
    }

    public FactionBtn getJuanqian() {
        if (juanqian == null) {
            if("水墨UI".equals(MyIsif.getStyle())) {
                juanqian = new FactionBtn("skin/8100226/newbutton/B22.png", 1, UIUtils.COLOR_WHITE2, "帮派捐钱", UIUtils.TEXT_HY88, 25,
                        this);
                juanqian.setBounds(545, 403, 99, 24);
            }else{
                juanqian = new FactionBtn("inkImg/hongmu/1/1_png.button.btn_xy.png", 1, UIUtils.COLOR_BTNPUTONG2, "帮派捐钱", UIUtils.TEXT_HY88, 25,
                        this);
                juanqian.setBounds(560, 363, 80, 26);
            }

            this.add(juanqian);

        }
        return juanqian;
    }

    public void setJuanqian(FactionBtn juanqian) {
        this.juanqian = juanqian;
    }

    public FactionBtn getBtnWarehouse() {
        if("水墨UI".equals(MyIsif.getStyle())) {

            if (btnWarehouse == null) {
                btnWarehouse = new FactionBtn("skin/8100226/newbutton/B22.png", 1, UIUtils.COLOR_WHITE2, "帮派仓库",
                        UIUtils.TEXT_HY16, 9, this);
                btnWarehouse.setBounds(545, 373, 99, 24);
                this.add(btnWarehouse);

            }
        }else{
            if (btnWarehouse == null) {
                btnWarehouse = new FactionBtn("inkImg/hongmu/1/1_png.button.btn_xy.png", 1, UIUtils.COLOR_BTNPUTONG2, "帮派仓库",
                        UIUtils.TEXT_HY88, 9, this);
                btnWarehouse.setBounds(560, 333, 80, 26);
                this.add(btnWarehouse);

            }
        }
        return btnWarehouse;
    }

    public void setBtnWarehouse(FactionBtn btnWarehouse) {
        this.btnWarehouse = btnWarehouse;
    }

    public FactionCardJpanel getFactionCardJpanel() {
        return factionCardJpanel;
    }

    public void setFactionCardJpanel(FactionCardJpanel factionCardJpanel) {
        this.factionCardJpanel = factionCardJpanel;
    }

    public GangGroupBtn getBtnFourTiger() {
        if (btnFourTiger == null) {
            btnFourTiger = new GangGroupBtn("skin/8100226/button/B292.png", 1, 0);
            btnFourTiger.setBounds(250, 180, 19, 18);
            this.add(btnFourTiger);
        }
        return btnFourTiger;
    }
    public GangGroupBtn getBtnFourDragon() {
        if (btnFourDragon == null) {
            btnFourDragon = new GangGroupBtn("skin/8100226/button/B294.png", 1, 0);
            btnFourDragon.setBounds(203, 202, 22, 19);
            this.add(btnFourDragon);
        }
        return btnFourDragon;
    }
    public GangGroupBtn getBtnFourRosefinch() {
        if (btnFourRosefinch == null) {
            btnFourRosefinch = new GangGroupBtn("skin/8100226/button/B293.png",1,0);
            btnFourRosefinch.setBounds(293, 204, 20, 22);
            this.add(btnFourRosefinch);
        }
        return btnFourRosefinch;
    }
    public GangGroupBtn getBtnFourTortoise() {
        if (btnFourTortoise == null) {
            btnFourTortoise = new GangGroupBtn("skin/8100226/button/B295.png",1,0);
            btnFourTortoise.setBounds(244, 224, 16, 22);
            this.add(btnFourTortoise);
        }
        return btnFourTortoise;
    }

    public GangGroupBtn getBtnDoor() {
        if (btnDoor == null) {
            btnDoor = new GangGroupBtn("skin/8100226/button/B300.png",1,0);
            btnDoor.setBounds(93, 231, 78, 59);
            this.add(btnDoor);
        }
        return btnDoor;
    }

    public GangGroupBtn getBtnDye() {
        if (btnDye == null) {
            btnDye = new GangGroupBtn("skin/8100226/button/B301.png",1,2023);
            btnDye.setBounds(427, 160, 102, 70);
            this.add(btnDye);
        }
        return btnDye;
    }

    public GangGroupBtn getBtnShop() {
        if (btnShop == null) {
            btnShop = new GangGroupBtn("skin/8100226/button/B302.png",1,0);
            btnShop.setBounds(50, 175, 57, 61);
            this.add(btnShop);
        }
        return btnShop;
    }

    public GangGroupBtn getBtnTownHall() {
        if (btnTownHall == null) {
            btnTownHall = new GangGroupBtn("skin/8100226/button/B304.png",1,0);
            btnTownHall.setBounds(438, 62, 87, 71);
            this.add(btnTownHall);
        }
        return btnTownHall;
    }

    public GangGroupBtn getBtnBase() {
        if (btnBase == null) {
            btnBase = new GangGroupBtn("skin/8100226/button/B305.png",1,2021);
            btnBase.setBounds(330, 93, 130, 88);
            this.add(btnBase);
        }
        return btnBase;
    }

    public GangGroupBtn getBtnTechfun() {
        if (btnTechfun == null) {
            btnTechfun = new GangGroupBtn("skin/8100226/button/B299.png",1,2022);
            btnTechfun.setBounds(379, 202, 108, 85);
            this.add(btnTechfun);
        }
        return btnTechfun;
    }
    
    public GangGroupBtn getBtnForge() {
        if (btnForge == null) {
            btnForge = new GangGroupBtn("skin/8100226/button/B298.png",1,0);
            btnForge.setBounds(305, 256, 86, 52);
            this.add(btnForge);
        }
        return btnForge;
    }

    public GangGroupBtn getBtnWare() {
        if (btnWare == null) {
            btnWare = new GangGroupBtn("skin/8100226/button/B297.png",1,0);
            btnWare.setBounds(279, 75, 99, 67);
            this.add(btnWare);
        }
        return btnWare;
    }

    public GangGroupBtn getBtnKylin() {
        if (btnKylin == null) {
            btnKylin = new GangGroupBtn("skin/8100226/button/B296.png",1,2026);
            btnKylin.setBounds(241, 179, 38, 47);
            this.add(btnKylin);
        }
        return btnKylin;
    }

    public GangGroupBtn getBtnTwoTiger() {
        if (btnTwoTiger == null) {
            btnTwoTiger = new GangGroupBtn("skin/8100226/button/B290.png",1,0);
            btnTwoTiger.setBounds(326, 134, 21, 32);
            this.add(btnTwoTiger);
        }
        return btnTwoTiger;
    }

    public GangGroupBtn getBtnTwoDragon() {
        if (btnTwoDragon == null) {
            btnTwoDragon = new GangGroupBtn("skin/8100226/button/B291.png",1,0);
            btnTwoDragon.setBounds(370, 160, 21, 27);
            this.add(btnTwoDragon);
        }
        return btnTwoDragon;
    }

    public GangGroupBtn[] getBtnArrTower() {
        if (btnArrTower == null) {
            btnArrTower = new GangGroupBtn[8];
            for (int i = 0; i < btnArrTower.length; i++) {// 24,42
                btnArrTower[i] = new GangGroupBtn("skin/8100226/button/B303.png", 1,0);
                this.add(btnArrTower[i]);
            }
            btnArrTower[0].setBounds(106, 276 - 42, 24, 42);
            btnArrTower[1].setBounds(152, 299 - 42, 24, 42);
            btnArrTower[2].setBounds(179, 244 - 42, 24, 42);
            btnArrTower[3].setBounds(210, 264 - 42, 24, 42);
            btnArrTower[4].setBounds(279, 190 - 42, 24, 42);
            btnArrTower[5].setBounds(312, 210 - 42, 24, 42);
            btnArrTower[6].setBounds(423, 100 - 42, 24, 42);
            btnArrTower[7].setBounds(496, 142 - 42, 24, 42);

        }
        return btnArrTower;
    }
}
